luci-app-firewall: fix zone log option
authorJan Froch <[email protected]>
Sun, 23 Feb 2025 18:39:49 +0000 (19:39 +0100)
committerPaul Donald <[email protected]>
Tue, 25 Feb 2025 19:59:57 +0000 (13:59 -0600)
Changes the zone log checkbox to a multivalue selection as the underlying uci option is a bitfield.

Signed-off-by: Jan Froch <[email protected]>
applications/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js

index 47b31cf0c19bbd6fa62c5f864ae41d071d808d1c..44d694ef5ae1dabbb5b840f3f9e19ec11b5924bc 100644 (file)
@@ -293,11 +293,23 @@ return view.extend({
                for (var i = 0; i < ctHelpers.length; i++)
                        o.value(ctHelpers[i].name, E('<span><span class="hide-close">%s (%s)</span><span class="hide-open">%s</span></span>'.format(ctHelpers[i].description, ctHelpers[i].name.toUpperCase(), ctHelpers[i].name.toUpperCase())));
 
-               o = s.taboption('advanced', form.Flag, 'log', _('Enable logging on this zone'));
+               o = s.taboption('advanced', form.MultiValue, 'log', _('Enable logging'), _('Log matched packets on the selected tables to syslog.'));
                o.modalonly = true;
+               o.value('filter');
+               o.value('mangle');
+               o.placeholder = 'No table selected';
+               const TABLES = { filter: 1, mangle: 2 };
+               o.cfgvalue = function (section_id) {
+                       let bitfield = this.super('load', [section_id]) || this.default;
+                       return Object.keys(TABLES).filter(table => bitfield & TABLES[table]);
+               };
+               o.write = function (section_id, value) {
+                       let bitfield = L.toArray(value).reduce((acc, table) => acc | (TABLES[table] || 0), 0);
+                       return this.super('write', [section_id, bitfield]);
+               };
 
                o = s.taboption('advanced', form.Value, 'log_limit', _('Limit log messages'));
-               o.depends('log', '1');
+               o.depends({log: [], "!reverse": true});
                o.placeholder = '10/minute';
                o.modalonly = true;